import { queryJiraData, queryTestData, queryTestData2 ,queryJiraDbAllMonthBug} from '../services/api';

import moment from 'moment';

export default {
  namespace: 'jira',

  state: {
    bug: {
      bugModel: [],
      bugProjectTotal: [],
      bugProjectHandUp: [],
      bugProjectTrend: [], // 趋势
      bugLeverProjectOlder: [], // 严重级别数据
      
    },

    test: {},
    SelectAllYear:{
      monthData:[],
    }
  },

  effects: {
    *fetchJiraData(_, { put, call }) {
      const reponse = yield call(queryJiraData);
      yield put({
        type: 'change',
        payload: { bug: reponse.data },
      });
    },

    *fetchTestData(_, { put, call }) {
      const reponse = yield call(queryTestData);
      yield put({
        type: 'change',
        payload: { ...reponse.data },
      });
    },

    *fetchJiraDbBugAll({payload},{put,call}){
      let {year}=payload;
      const response =yield call (queryJiraDbAllMonthBug,year);
     

      yield put({
        type:'concat',
        payload:{SelectAllYear: {monthData:response.data} },
      })
    },

  },

  reducers: {
    change(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },

    concat(state,{payload}){
      return{
        ...state,
        ...payload,
      }
    }
  },

};
